package leetcode.数组;

/**
 * @author: levi
 * @description: https://leetcode.cn/problems/merge-sorted-array/
 * @date: 2022-9-13 14:47
 * @version: 1.0
 */
public class 合并两个有序数组_88 {
    public static void main(String[] args) {
        // merge();
    }

    public static void merge(int[] nums1, int m, int[] nums2, int n) {
        int tempNumsLen = m + n;
        int[] temp = new int[tempNumsLen];
        int index1 = 0,index2 = 0;

        for (int i = 0; i < tempNumsLen; i++) {
            if(index1 >= m){
                temp[i] = nums1[index1];
                index1 ++;
            }else if(index2 >= n){
                temp[i] = nums1[index2];
                index2 ++;
            } else if(nums1[index1] > nums2[index2]){
                temp[i] = nums2[index2];
                index2 ++;
            }else{
                temp[i] = nums1[index1];
                index1 ++;
            }
        }
        for (int i = 0; i < temp.length; i++) {
            nums1[i] = temp[i];
        }
    }
}
